#ifndef _GL_WINDOW_H
#define _GL_WINDOW_H

#include <QGLWidget>

class QTimer;
class Board;

class GlWindow : public QGLWidget
{
    Q_OBJECT

    public:
        //Constructor
        GlWindow(QWidget *parent=0);
   		~GlWindow();

        QSize minimumSizeHint() const;
        QSize sizeHint() const;

        
        void setAnimationSetting( bool );
        bool getAnimationSetting();
        void setRegularMovesSetting( bool );
        bool getRegularMovesSetting();
        void setLastMoveSetting( bool );
        bool getLastMoveSetting();
        
        void setBoard(Board*);
        
    public slots:
        void updateGL();
        void updateScene();
        
        void askingMoveReceived();
		

    protected:
        void initializeGL();
        void resizeGL(int width, int height);
        void paintGL();
		void pawnDrawing(GLUquadricObj *);
		void regularMoveDrawing(GLUquadricObj *);
		void lastMoveDrawing(GLUquadricObj *);
		void drawPawnsLayout();
		
		void mousePressEvent(QMouseEvent *);
  		void mouseReleaseEvent(QMouseEvent *);
  		
	private:
		Board *board;
		
		GLuint makeBoard();
		void loadTextures();
		
		GLuint textures[1];
		GLuint boardLayout;
		QColor clearColor;
		
		//Paramètres d'affichages
		bool animationSetting;
		bool regularMovesSetting;
		bool lastMoveSetting;
		
		bool animated;  //Animation en cours?
		void setAnimated( bool );
		bool getAnimated();
		
		int angle;
		
		QTimer *timer;
		
		//Demande de coup du moteur de jeu
		bool moveAsked;
		void setMoveAsked(bool);
		bool getMoveAsked();
	
	signals:
		void boardHasClicked(int,int);
		void animationDone();

};

#endif
